#include "stdafx.h"
#include "DBProto.h"
#include "DBServer.h"


void DecodePKG_ROLEDATA_NTF_ID(const void * buf, int nSize, CDBServer * pProc)
{
    shared_ptr<PKG_ROLEDATA_NTF> pkg(new PKG_ROLEDATA_NTF);
    if (!pkg->ParseFromArray(buf, nSize))
        return;
    if (pProc){
        pProc->OnGetRoleData(pkg);
    }
}

CDBProto::CDBProto()
{
    GOOGLE_PROTOBUF_VERIFY_VERSION;
    memset(m_DecodeFuncArray, 0, sizeof(m_DecodeFuncArray));
    Init();
}

CDBProto::~CDBProto()
{
    google::protobuf::ShutdownProtobufLibrary();
}

bool CDBProto::Init()
{
    m_DecodeFuncArray[PKG_ROLEDATA_NTF_ID] = &DecodePKG_ROLEDATA_NTF_ID;
    return true;
}

void CDBProto::Decode(int nMsgID, const void * buf, int nSize, CDBServer * pProc)
{
    if(nMsgID > DBProtoMaxMessageID || m_DecodeFuncArray[nMsgID] == NULL){
        return;
    }
    m_DecodeFuncArray[nMsgID](buf, nSize, pProc);
}

